<template>
  <div>
    <NavBar title="即时招聘" />
    <!-- 列表 start -->
    <van-list class="news-list content-top" v-model="loading" :finished="finished" finished-text="没有更多了">
      <div class="news-item" :class="{ red: item.IsRed === 1, new: item.IsNew === 1 }" v-for="(item, index) in list" :key="index" @click="onItem(item)">
        <p>
          <b>{{ item.title }}</b>
        </p>
        <p>
          <span>
            <van-icon name="clock-o" size="13" color="#aaa" />{{ item.pubDateStr }}
          </span>
          <span>
            <van-icon name="eye-o" size="13" color="#aaa" />{{ item.times }}
          </span>
        </p>
      </div>
    </van-list>
    <!-- 列表 end -->
  </div>
</template>

<script>
import { List, Icon } from "vant"
import NavBar from '@/components/NavBar.vue'

export default {
  name: 'NewsList',
  components: {
    NavBar,
    [List.name]: List,
    [Icon.name]: Icon,
  },
  // 定义属性
  data() {
    return {
      typeid: 0,
      loading: true,
      finished: false,
      list: [],
    }
  },
  mounted() {
    this.onLoad();
  },
  // 方法集合
  methods: {
    onLoad() {
      this.$api.get('/Wap/GetNewsPageList', { pageIndex: 1, pageSize: 100 }).then(res => {
        this.loading = false;
        if (res.success) {
          this.finished = true;
          this.list = res.response;
        }
      })
    },
    onItem(item) {
      this.$router.push({ name: 'person-news-info', query: { news_id: item.news_id } })
    }
  },
}
</script>

<style scoped>
@import "./news.css";
</style>